
<style>
.ui-widget input{
	font-size: 10pt;
}
</style>
<script type="text/javascript">
$(function() {
	$( "#tabs-news" ).tabs();
	
});
hs.graphicsDir = '<?php echo Yii::app()->getAssetManager()->publish(Yii::app()->basePath.'/extensions/highslide/assets');?>/graphics/';
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'draggable-header';
hs.showCredits = false;
</script>
<div class="form">
<?php 
$this->widget('ext.highslide.HighSlide', array('mode'=>'html'));
$form = $this->beginWidget('GxActiveForm', array(
	'id' => 'news-form',
	'enableAjaxValidation' => false,
	'htmlOptions'=>array('enctype'=>'multipart/form-data', 'name'=>'news-form'),
));
?>

<div id="tabs-news">
	<ul>
		<li><a href="#main-news"><?php echo Yii::t('admin_news','Content News')?></a></li>
		<li><a href="#images"><?php echo Yii::t('admin_news','Content Images')?></a></li>
	</ul>
	<div id="main-news">
	<div class="mini-bl">
		<table>
			<tr>
				<td><?php echo $form->labelEx($model,'status'); ?></td>
				<td><?php echo $form->dropDownList($model,'status',Lookup::items('PostStatus')); ?></td>
			</tr>
			<tr><td><?php echo $form->labelEx($model,'comment'); ?></td>
				<td><?php echo $form->checkBox($model, 'comment'); ?>
					<?php echo $form->error($model,'comment'); ?>
				</td>
			</tr>
			<tr>
			<td><?php echo $form->labelEx($model,'created'); ?></td>
			<td colspan="3">
			<?php 
				$this->widget('ext.widgets.CJuiDateTimePicker.CJuiDateTimePicker',array(
			        'model'=>$model, //Model object
			        'attribute'=>'created', //attribute name
			        'mode'=>'datetime', //use "time","date" or "datetime" (default)
					'options'=>array()
			    ));
			?>
			<?php echo $form->error($model,'created'); ?>
		</td><!-- row -->
		<tr>
		<td><?php echo $form->labelEx($model,'created_by'); ?></td>
		<td>
		<?php 
		$u_create = iUsers::model()->findByPk($model->created_by);
		if(is_object($u_create)) 
			echo $u_create->username;
		?>
		</td><!-- row --></td>
		</tr>
			<tr>
				<td>
					<?php echo $form->labelEx($model,'modified'); ?>
				</td>
				<td colspan="3"><?php 
						$this->widget('ext.widgets.CJuiDateTimePicker.CJuiDateTimePicker',array(
					        'model'=>$model, //Model object
					        'attribute'=>'modified', //attribute name
					        'mode'=>'datetime', //use "time","date" or "datetime" (default)
							'options'=>array()
					    ));
					?>
					<?php echo $form->error($model,'modified'); ?>
					</td>
			<tr><td><?php echo $form->labelEx($model,'modified_by');?></td>
					<td><?php 
					$u_modified = iUsers::model()->findByPk($model->modified_by);
					if(is_object($u_modified))
						echo $u_modified->username;
					?>
				</td>
			</tr>
	</table>
</div>
	<p class="note">
		<?php echo Yii::t('app', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
	</p>
		
		<?php echo $form->errorSummary($model); ?>
		
		<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model, 'title', array('maxlength' => 255, 'class'=>'textField-l')); ?>
		<?php echo $form->error($model,'title'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'alias'); ?>
		<?php echo $form->textField($model, 'alias', array('class'=>'textField-l')); ?>
		<?php echo $form->error($model,'alias'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'catid'); ?>
		<?php
			$call_cats =Categories::model()->findAll('published=:p ORDER BY position ASC', array(':p'=>1));
			$cats = CHtml::listData($call_cats, 'id', 'title_tree');
			echo $form->dropDownList($model,'catid', $cats);
			
		?>
		<?php echo $form->error($model,'catid'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'introtext'); ?>
		<?php
		$this->widget('application.extensions.elrte.elRTE', array(
		    'selector'=>'News_introtext',
		    'doctype' => '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">',
		    'cssClass' => 'el-rte',
		    'absoluteURLs' => 'false',
		    'allowSource' => 'true',
		    'lang' => 'en',
		    'styleWithCSS' => 'true',
		    'height' => '150',
		    'width' => '100%',
		    'fmAllow' => 'true',
		    'toolbar' => 'normal',
		 ));
		  echo $form->textArea($model, 'introtext');
		?>
		<?php echo $form->error($model,'introtext'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'fulltext'); ?>
		<?php
		$this->widget('application.extensions.elrte.elRTE', array(
		    'selector'=>'News_fulltext',
		    'doctype' => '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">',
		    'cssClass' => 'el-rte',
		    'absoluteURLs' => 'false',
		    'allowSource' => 'true',
		    'lang' => 'en',
		    'styleWithCSS' => 'true',
		    'height' => '500',
		    'width' => '100%',
		    'fmAllow' => 'true',
		    'toolbar' => 'maxi',
		 ));
		  echo $form->textArea($model, 'fulltext'); 
		?>
		<?php echo $form->error($model,'fulltext'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'ordering'); ?>
		<?php echo $form->textField($model, 'ordering'); ?>
		<?php echo $form->error($model,'ordering'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'metakey'); ?>
		<?php echo $form->textArea($model, 'metakey', array('class'=>'textarea-m')); ?>
		<?php echo $form->error($model,'metakey'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'metadesc'); ?>
		<?php echo $form->textArea($model, 'metadesc', array('class'=>'textarea-m')); ?>
		<?php echo $form->error($model,'metadesc'); ?>
		</div><!-- row -->
		
	</div>
	<div id="images">
	<?php 
		$images = ($model->images!='')?unserialize($model->images):null;
		$Images_Types = ContentImages::model()->findAll();
		if(count($Images_Types)>0){
			foreach ($Images_Types as $value){
				$image = ($images!=null)?Yii::app()->params['site_url'].$images["{$value['name']}"]["url"]:'';
				$size = Array();
				if($image!=''){
					$size = @getimagesize($image);
				}
				?>
				
				<div class="row">
				<fieldset>
					<legend><label><?php echo $value['name']?> (<?php echo $value['width'].'x'.$value['height']?>)</label></legend>
					<div class="toolb-i">
					<div class="w-button">
					<?php echo CHtml::fileField("{$value['name']}", '',array('class'=>'file-upload'));?>
					<div class="icon-upload">Upload</div>
					</div>
					<?php 
					if($size && $size[0]>$value['width'] && $size[1]>$value['height']):?>
					<div class="w-button">
						<a class="i-crop" href="<?php echo Yii::app()->createUrl('/admin_news/news/crop', array('url'=>$images["{$value['name']}"]["url"], 'width'=>$value['width'], 'height'=>$value['height']));?>" onclick="return hs.htmlExpand(this, { objectType: 'iframe', headingText: 'Crop Image with size: <?php echo $value['width']?>x<?php echo $value['height'];?>' } )">
						Crop
						</a>
					</div>
					<?php endif;?>
					<?php 
					if($size):?>
					<div class="w-button">
						<a class="i-del" href="<?php echo Yii::app()->createUrl('/admin_news/news/delimage', array('url'=>$images["{$value['name']}"]["url"],'id'=>$model->id));?>">
						<?php echo Yii::t('app','Delete');?>
						</a>
					</div>
					<?php endif;?>
					</div>
					<?php 
					if($size):
					?>
					<div><?php echo $size[0].'x'.$size[1];?></div>
					<img id="<?php echo $value['name'];?>_image" width="<?php echo $value['width']?>" height="<?php echo $value['height']?>" src="<?php echo $image;?>" />
					<?php endif;?>
					
				</fieldset>
				</div>
				<?php
			}
		}
	?>
	</div>
</div>
	
		
<?php
echo GxHtml::submitButton(Yii::t('app', 'Save'), array('id'=>'s-bt','style'=>'display: none'));
$this->endWidget();
?>
</div><!-- form -->

<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("#News_title").blur(function(){
		jQuery.ajax({
			url: '<?php echo Yii::app()->createUrl('/admin_news/common/renalias');?>',
			data: {title:this.value},
			dataType:'json',
			success: function(msg){
			   	jQuery("#News_alias").attr("value",msg.title)
			  }
		})
	})
})
</script>
